home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- # --------------------------------------------------------------------------
- # Copyright 1992 by Forschungszentrum Informatik (FZI)
- #
- # You can use and distribute this software under the terms of the licence
- # you should have received along with this program.
- # If not or if you want additional information, write to
- # Forschungszentrum Informatik, "STONE", Haid-und-Neu-Strasse 10-14,
- # D-7500 Karlsruhe 1, Germany.
- # --------------------------------------------------------------------------
- # 'sos-scp - 06:06:91 - Dietmar Theobald'
- #
- # sos-scp [<schema>] [-o <outfile>] <infile>
- #
- # 'sos-scp' calls the SOS C++ preprocessor 'scp' on <infile>.
- # <infile> contains method implemetations for <schema>, output is written to
- # <outfile>.
- #
- # <schema> may be omitted if the directory containing <infile> contains a single
- # schema file '*.sos'. In this case <schema> will be set to '*'.
- #
- # <outfile> may be omitted if <infile> is matched by '*.c', '*.cc', or '*.C'.
- # In this case output will be written to '*_scp.c' in the same directory as
- # <infile>.
- #
- BINDIR=${SOSPATH-__SOS_INSTALLED_PATH__}/bin/
-
- test="${SOSCONTAINER?}"
- tmpfile=/tmp/sos-scp$$
-
- while [ $# -gt 0 ] ; do
- case "$1" in
- -o) shift
- [ "$outfile" ] && { err='+'; break ;} ; outfile="$1" ;;
- *.C|*.cc|*.c) [ "$infile" ] && { err='+'; break ;} ; infile="$1" ;;
- *) [ "$schema" ] && { err='+'; break ;} ; schema="$1" ;;
- esac
- shift
- done
- if [ -z "$infile" -o $# -gt 0 -o -n "$err" ] ; then
- err='+'
- else
- [ "$schema" ] || {
- set `dirname "$infile"`/*.sos ""
-
- if [ $# -gt 2 ] ; then
- echo >&2 '*** sos-scp: several SOS schema files in '`dirname "$1"`
- exit 1
- elif [ -f "$1" ] ; then
- schema=`basename "$1" .sos`
- else
- echo >&2 '*** sos-scp: no SOS schema file in '`dirname "$1"`
- exit 1
- fi
- }
- [ "$outfile" ] || {
- outfile=`expr match "$infile" '\(.*\)\.[^.]*'`_scp.c
- [ "$outfile" = '_scp.c' ] && err='+'
- }
- fi
- [ "$err" ] && { echo >&2 '*** usage: sos-scp [<schema>] <infile> [-o <outfile>]'
- exit 1
- }
-
- wd=`pwd`
-
- cd `dirname $infile` ||
- { echo >&2 "*** sos-scp: no directory `dirname $infile`"; exit 1; }
- infile=`pwd`/`basename $infile`
-
- cd $wd
- cd `dirname $outfile` ||
- { echo >&2 "*** sos-scp: no directory `dirname $outfile`"; exit 1; }
- outfile=`basename $outfile`
-
- trap "rm -f $tmpfile; exit 1" 1 2 3 6 10 11
-
- ${BINDIR}scp $schema $infile > $tmpfile || { rm -f $tmpfile ; exit 1 ;}
-
- rm -f $outfile
- cat $tmpfile > $outfile
- rm -f $tmpfile
-